<?php
/**
 * Created by PhpStorm.
 * User: LI
 * Date: 2015/11/25
 * Time: 14:35
 */
namespace Home\Controller;
use Think\Controller;
use Home\Model;

class CarController extends Controller{
   public function index(){
       $this -> display('index');
   }

   public function buy(){
      $car_list = D('Car');
      $data = $car_list->getCarList();     
      $keysvalue = array();
      $new_array = array();
    foreach($data as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){
        $new_array[$k] = $data[$k];             
        $condition['b_id'] = $data[$k]['brand'];
        $brand=$car_list->table('car_brand')->where($condition)->find();      
        $new_array[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $data[$k]['image']);
        $new_array[$k]['img'] = $image_list[0];
    }
      

    $car_list_low = D('Car');
    $conditionlow['price'] = array(between,array('0','10'));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datalow = $car_list_low->getCarList($conditionlow);     
      $keysvalue = array();
      $new_array_low = array();
    foreach($datalow as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_low[$k] = $datalow[$k];             
        $condition['b_id'] = $datalow[$k]['brand'];
        $brand=$car_list_low->table('car_brand')->where($condition)->find();      
        $new_array_low[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datalow[$k]['image']);
        $new_array_low[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_low',$new_array_low);

    $car_list_mid = D('Car');
    $conditionmid['price'] = array(between,array('10','30'));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datamid = $car_list_mid->getCarList($conditionmid);     
      $keysvalue = array();
      $new_array_mid = array();
    foreach($datamid as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_mid[$k] = $datamid[$k];             
        $condition['b_id'] = $datamid[$k]['brand'];
        $brand=$car_list_mid->table('car_brand')->where($condition)->find();      
        $new_array_mid[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datamid[$k]['image']);
        $new_array_mid[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_mid',$new_array_mid);

    $car_list_high = D('Car');
    $conditionhigh['price'] = array(between,array('30','999999'));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datahigh = $car_list_high->getCarList($conditionhigh);     
      $keysvalue = array();
      $new_array_high = array();
    foreach($datahigh as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_high[$k] = $datahigh[$k];             
        $condition['b_id'] = $datahigh[$k]['brand'];
        $brand=$car_list_high->table('car_brand')->where($condition)->find();      
        $new_array_high[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datahigh[$k]['image']);
        $new_array_high[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_high',$new_array_high);

      $look_list = M('Lookcar');
      $lookdata  = $look_list->select();     
      $keysvalue = array();
      $new_array_look = array();
    foreach($lookdata as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){
        $new_array_look[$k] = $lookdata[$k];             
        $condition['b_id'] = $lookdata[$k]['brand'];
        $brand=$look_list->table('car_brand')->where($condition)->find();      
        $new_array_look[$k]['brand'] = $brand['b_name'] ; 
    }
      $this->assign('look_list',$new_array_look);
      $this->assign('car_list',$new_array);
      $this -> display('buy');
   }

   public function sell01(){
    $backurl = empty($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 
           $_SERVER['HTTP_HOST']) ?  '#' : $_SERVER['HTTP_REFERER'];
       $this->assign('backurl', $backurl);
       $this -> display('sell01');
   }

   public function sell02(){
        $backurl = empty($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 
           $_SERVER['HTTP_HOST']) ?  '#' : $_SERVER['HTTP_REFERER'];
        $this->assign('backurl', $backurl);
    if(($_SESSION['LoginName'])&&($_SESSION['is_login'])) {
      $this->display('sell02');
    }else{
      $this -> error('请先登陆');
    } 
   }

   public function sellsumbit(){
    $add_list = M('Car');
    $condition=array(
      'brand'       =>  $_POST['p_brand'],
      'carname'     =>  $_POST['p_name'],
      'model'       =>  $_POST['p_model'],
      'price'       =>  $_POST['p_price'],
      'color'       =>  $_POST['p_color'],
      'gas'         =>  $_POST['p_gas'],
      'transmission'=>  $_POST['p_transmission'],
      'year'        =>  $_POST['p_year'],
      'month'       =>  $_POST['p_month'],
      'kilometre'   =>  $_POST['p_kilometre'],
      'country'     =>  $_POST['p_country'],
      'image'       =>  $_POST['file'],
      'exatime'     =>  $_POST['p_exatime'],
      'securedate'  =>  $_POST['p_securedate'],
      'tax'         =>  $_POST['p_tax'],
      'productiontime'=>$_POST['p_productiontime'],
      'details'     =>  $_POST['p_details'],
      'username'    =>  $_POST['p_username'],
      'tel'         =>  $_POST['p_tel'],
      'send_name'   =>  $_SESSION['LoginName'],
      'send_time'   =>  time(),    
    );
    $car_add=$add_list->add($condition);    
    $this ->success('发布成功！','buy');
    }

    public function looksumbit(){
      
    $look_list = M('Lookcar');
    $condition=array(
      'brand'       =>  $_POST['p_brand'],
      'carname'     =>  $_POST['p_name'],
      'model'       =>  $_POST['p_model'],
      'price'       =>  $_POST['p_price'],
      'year'        =>  $_POST['year'],
      'kilometre'   =>  $_POST['p_kilometre'],
      'details'     =>  $_POST['p_details'],
      'user_name'   =>  $_POST['user_name'],
      'user_tel'    =>  $_POST['user_tel'],
      'send_name'   =>  $_SESSION['LoginName'],
      'send_time'   =>  time(),   
    );
    $look_add=$look_list->add($condition);    
    $this ->success('发布成功！','buy');
    } 


    public function details(){
      $car_list = D('Car');
      $condition = array(
        'id' => $_GET['car_id']
      );
      $data= $car_list->where($condition)->select();
      $imagess = trim($data['image'], ',');
      $image_list = explode(',', $imagess);
      $detail_list = array();
      foreach($data as $k=>$v){
        $detail_list[$k] = $data[$k];             
        $condition['b_id'] = $data[$k]['brand'];
        $brand=$car_list->table('car_brand')->where($condition)->find();      
        $detail_list[$k]['brand'] = $brand['b_name'] ; 
        $images = trim($data[$k]['image'], ',');
        $image_list = explode(',', $images);
        $detail_list[$k]['img'] = $image_list[0];
        $condition_m['m_id'] = $data[$k]['model'];
        $model=$car_list->table('car_model')->where($condition_m)->find(); 
        $detail_list[$k]['model'] = $model['m_name'] ;  
    }

    
    
    $car_list_modle = D('Car');
    $conditionmodle['model'] = $detail_list[$k]['model'];
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datamodle = $car_list_modle->getCarList($conditionmodle);     
      $keysvalue = array();
      $new_array_modle = array();
    foreach($datamodle as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_modle[$k] = $datamodle[$k];             
        $condition['b_id'] = $datamodle[$k]['brand'];
        $brand=$car_list_modle->table('car_brand')->where($condition)->find();      
        $new_array_modle[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datamodle[$k]['image']);
        $new_array_modle[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_modle',$new_array_modle);

    $car_list_price = D('Car');
    $conditionprice['price'] = $detail_list[$k]['price'];
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $dataprice = $car_list_price->getCarList($conditionmodle);     
      $keysvalue = array();
      $new_array_price = array();
    foreach($dataprice as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_price[$k] = $dataprice[$k];             
        $condition['b_id'] = $dataprice[$k]['brand'];
        $brand=$car_list_price->table('car_brand')->where($condition)->find();      
        $new_array_price[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $dataprice[$k]['image']);
        $new_array_price[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_price',$new_array_price);

      $this->assign('detail_list',$detail_list);     
      $this->assign('image_list',$image_list);
      $this->display('details');
    }

    public function searchModel(){
      $car_list = D('Car');
      $condition['model'] = $_GET['m_id'];
      $data = $car_list->getCarList($condition);     
      $keysvalue = array();
      $new_array = array();
    foreach($data as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){
        $new_array[$k] = $data[$k];             
        $condition['b_id'] = $data[$k]['brand'];
        $brand=$car_list->table('car_brand')->where($condition)->find();      
        $new_array[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $data[$k]['image']);
        $new_array[$k]['img'] = $image_list[0];
    }
      
      $this->assign('car_list',$new_array);
      $this -> display('buy');
   }

    public function searchPrice(){
      $car_list = D('Car');
      $condition['price'] = array(between,array($_GET['small'],$_GET['big']));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $data = $car_list->getCarList($condition);     
      $keysvalue = array();
      $new_array = array();
    foreach($data as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array[$k] = $data[$k];             
        $condition['b_id'] = $data[$k]['brand'];
        $brand=$car_list->table('car_brand')->where($condition)->find();      
        $new_array[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $data[$k]['image']);
        $new_array[$k]['img'] = $image_list[0];
    }
    $car_list_low = D('Car');
    $conditionlow['price'] = array(between,array('0','10'));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datalow = $car_list_low->getCarList($conditionlow);     
      $keysvalue = array();
      $new_array_low = array();
    foreach($datalow as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_low[$k] = $datalow[$k];             
        $condition['b_id'] = $datalow[$k]['brand'];
        $brand=$car_list_low->table('car_brand')->where($condition)->find();      
        $new_array_low[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datalow[$k]['image']);
        $new_array_low[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_low',$new_array_low);

    $car_list_mid = D('Car');
    $conditionmid['price'] = array(between,array('10','30'));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datamid = $car_list_mid->getCarList($conditionmid);     
      $keysvalue = array();
      $new_array_mid = array();
    foreach($datamid as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_mid[$k] = $datamid[$k];             
        $condition['b_id'] = $datamid[$k]['brand'];
        $brand=$car_list_mid->table('car_brand')->where($condition)->find();      
        $new_array_mid[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datamid[$k]['image']);
        $new_array_mid[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_mid',$new_array_mid);

    $car_list_high = D('Car');
    $conditionhigh['price'] = array(between,array('30','999999'));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datahigh = $car_list_high->getCarList($conditionhigh);     
      $keysvalue = array();
      $new_array_high = array();
    foreach($datahigh as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_high[$k] = $datahigh[$k];             
        $condition['b_id'] = $datahigh[$k]['brand'];
        $brand=$car_list_high->table('car_brand')->where($condition)->find();      
        $new_array_high[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datahigh[$k]['image']);
        $new_array_high[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_high',$new_array_high);
 
      $this->assign('car_list',$new_array);
      $this -> display('buy');
   }

    public function searchAge(){
      $car_list = D('Car');
      $age = date("Y", time())- $_GET['age'];
      if($_GET['age'] == 7){
        $condition['year'] = array('lt',$age);

      }else {
        $condition['year'] = array('gt',$age);
      }
      $data = $car_list->getCarList($condition);     
      $keysvalue = array();
      $new_array = array();
    foreach($data as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array[$k] = $data[$k];             
        $condition['b_id'] = $data[$k]['brand'];
        $brand=$car_list->table('car_brand')->where($condition)->find();      
        $new_array[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $data[$k]['image']);
        $new_array[$k]['img'] = $image_list[0];
    }
    $car_list_low = D('Car');
    $conditionlow['price'] = array(between,array('0','10'));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datalow = $car_list_low->getCarList($conditionlow);     
      $keysvalue = array();
      $new_array_low = array();
    foreach($datalow as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_low[$k] = $datalow[$k];             
        $condition['b_id'] = $datalow[$k]['brand'];
        $brand=$car_list_low->table('car_brand')->where($condition)->find();      
        $new_array_low[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datalow[$k]['image']);
        $new_array_low[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_low',$new_array_low);

    $car_list_mid = D('Car');
    $conditionmid['price'] = array(between,array('10','30'));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datamid = $car_list_mid->getCarList($conditionmid);     
      $keysvalue = array();
      $new_array_mid = array();
    foreach($datamid as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_mid[$k] = $datamid[$k];             
        $condition['b_id'] = $datamid[$k]['brand'];
        $brand=$car_list_mid->table('car_brand')->where($condition)->find();      
        $new_array_mid[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datamid[$k]['image']);
        $new_array_mid[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_mid',$new_array_mid);

    $car_list_high = D('Car');
    $conditionhigh['price'] = array(between,array('30','999999'));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datahigh = $car_list_high->getCarList($conditionhigh);     
      $keysvalue = array();
      $new_array_high = array();
    foreach($datahigh as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_high[$k] = $datahigh[$k];             
        $condition['b_id'] = $datahigh[$k]['brand'];
        $brand=$car_list_high->table('car_brand')->where($condition)->find();      
        $new_array_high[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datahigh[$k]['image']);
        $new_array_high[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_high',$new_array_high);

      $this->assign('car_list',$new_array);
      $this -> display('buy');
   }

    public function searchGas(){
      $car_list = D('Car');
      $condition['gas'] = $_GET['g'];
      $data = $car_list->getCarList($condition);     
      $keysvalue = array();
      $new_array = array();
    foreach($data as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){
        $new_array[$k] = $data[$k];             
        $condition['b_id'] = $data[$k]['brand'];
        $brand=$car_list->table('car_brand')->where($condition)->find();      
        $new_array[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $data[$k]['image']);
        $new_array[$k]['img'] = $image_list[0];
    }
    $car_list_low = D('Car');
    $conditionlow['price'] = array(between,array('0','10'));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datalow = $car_list_low->getCarList($conditionlow);    
      $keysvalue = array();
      $new_array_low = array();
    foreach($datalow as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_low[$k] = $datalow[$k];             
        $condition['b_id'] = $datalow[$k]['brand'];
        $brand=$car_list_low->table('car_brand')->where($condition)->find();      
        $new_array_low[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datalow[$k]['image']);
        $new_array_low[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_low',$new_array_low);

    $car_list_mid = D('Car');
    $conditionmid['price'] = array(between,array('10','30'));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datamid = $car_list_mid->getCarList($conditionmid);   
      $keysvalue = array();
      $new_array_mid = array();
    foreach($datamid as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_mid[$k] = $datamid[$k];             
        $condition['b_id'] = $datamid[$k]['brand'];
        $brand=$car_list_mid->table('car_brand')->where($condition)->find();      
        $new_array_mid[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datamid[$k]['image']);
        $new_array_mid[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_mid',$new_array_mid);

    $car_list_high = D('Car');
    $conditionhigh['price'] = array(between,array('30','999999'));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datahigh = $car_list_high->getCarList($conditionhigh);     
      $keysvalue = array();
      $new_array_high = array();
    foreach($datahigh as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_high[$k] = $datahigh[$k];             
        $condition['b_id'] = $datahigh[$k]['brand'];
        $brand=$car_list_high->table('car_brand')->where($condition)->find();      
        $new_array_high[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datahigh[$k]['image']);
        $new_array_high[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_high',$new_array_high);
      
      $this->assign('car_list',$new_array);
      $this -> display('buy');
   }
   public function searchBrand(){
      $car_list = D('Car');
      $condition['brand'] = $_GET['select'];
      $data = $car_list->getCarList($condition);    
      $keysvalue = array();
      $new_array = array();
    foreach($data as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){
        $new_array[$k] = $data[$k];             
        $condition['b_id'] = $data[$k]['brand'];
        $brand=$car_list->table('car_brand')->where($condition)->find();      
        $new_array[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $data[$k]['image']);
        $new_array[$k]['img'] = $image_list[0];
    }
      $car_list_low = D('Car');
    $conditionlow['price'] = array(between,array('0','10'));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datalow = $car_list_low->getCarList($conditionlow);     
      $keysvalue = array();
      $new_array_low = array();
    foreach($datalow as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_low[$k] = $datalow[$k];             
        $condition['b_id'] = $datalow[$k]['brand'];
        $brand=$car_list_low->table('car_brand')->where($condition)->find();      
        $new_array_low[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datalow[$k]['image']);
        $new_array_low[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_low',$new_array_low);

    $car_list_mid = D('Car');
    $conditionmid['price'] = array(between,array('10','30'));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datamid = $car_list_mid->getCarList($conditionmid);     
      $keysvalue = array();
      $new_array_mid = array();
    foreach($datamid as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_mid[$k] = $datamid[$k];             
        $condition['b_id'] = $datamid[$k]['brand'];
        $brand=$car_list_mid->table('car_brand')->where($condition)->find();      
        $new_array_mid[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datamid[$k]['image']);
        $new_array_mid[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_mid',$new_array_mid);

    $car_list_high = D('Car');
    $conditionhigh['price'] = array(between,array('30','999999'));
      //$condition['price'] = array(array('gt',$_GET['small']),array('lt',$_GET['big']));
      $datahigh = $car_list_high->getCarList($conditionhigh);     
      $keysvalue = array();
      $new_array_high = array();
    foreach($datahigh as $k=>$v){
      $keysvalue[$k] = $v['time'];
    }
    arsort($keysvalue);
    reset($keysvalue);
        foreach($keysvalue as $k=>$v){

        $new_array_high[$k] = $datahigh[$k];             
        $condition['b_id'] = $datahigh[$k]['brand'];
        $brand=$car_list_high->table('car_brand')->where($condition)->find();      
        $new_array_high[$k]['brand'] = $brand['b_name'] ; 
        $image_list = explode(',', $datahigh[$k]['image']);
        $new_array_high[$k]['img'] = $image_list[0];
    }
      $this->assign('car_list_high',$new_array_high);

      $this->assign('car_list',$new_array);
      $this -> display('buy');
   }
   public function look(){
    $backurl = empty($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 
           $_SERVER['HTTP_HOST']) ?  '#' : $_SERVER['HTTP_REFERER'];
        $this->assign('backurl', $backurl);
    if(($_SESSION['LoginName'])&&($_SESSION['is_login'])) {
     $this -> display('look');
    }else{
      $this -> error('请先登陆');
    } 
  }

  public function news(){
    $this -> display('news');
  }
  public function user_index(){
    $this -> display('user_index');
  }
}
?>